<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../plugins/elementui/index.css">
    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/style.css">
    <style type="text/css">
    .el-main{
        position: absolute;
        top: 70px;
        bottom: 0px;
        left: 200px;
        right: 10px;
        padding: 0;
    }
    </style>
</head>
<body class="hold-transition skin-purple sidebar-mini">
    <div id="app">
        <el-container>
            <el-header  class="main-header" style="height:70px;">
                <nav class="navbar navbar-static-top" :class=''>
                    <!-- Logo -->
                    <a href="#" class="logo" style="text-align:center">
                        <span class="logo-lg"><img src="../img/logo.png"></span>
                    </a>
                    <div class="right-menu">
                        <span class="help"><i class="fa fa-exclamation-circle" aria-hidden="true"></i>帮助</span>
                        <el-dropdown class="avatar-container right-menu-item" trigger="click">
                            <div class="avatar-wrapper">
                                <img src="../img/user2-160x160.jpg" class="user-avatar">
                                {{username}}
                            </div>
                            <el-dropdown-menu slot="dropdown">
                                <el-dropdown-item divided>
                                    <span style="display:block;" @click="editPassword()">修改密码</span>
                                </el-dropdown-item>
                                <el-dropdown-item divided>
                                        <span style="display:block;"><a href="/logout.do"> 退出</a></span>
                                    </el-dropdown-item>
                            </el-dropdown-menu>
                        </el-dropdown>
                    </div>
                </nav>
            </el-header>
            <el-container>
                <el-aside width="200px">
                    <el-menu>
                        <el-submenu v-for="menu in menuList" :index="menu.path">
                            <template slot="title">
                                <i class="fa" :class="menu.icon"></i>
                                {{menu.name}}
                            </template>
                            <template v-for="child in menu.children">
                                <el-menu-item :index="child.path">
                                    <a :href="child.linkUrl" target="right">{{child.name}}</a>
                                </el-menu-item>
                            </template>
                        </el-submenu>
                    </el-menu>
                </el-aside>
                <el-container>
                    <iframe name="right" class="el-main" src="ordersetting.html" width="100%" height="580px" frameborder="0"></iframe>
                </el-container>
            </el-container>
        </el-container>

        <!--修改密码弹框-->
        <div class="add-form">
            <el-dialog title="修改密码" :visible.sync="changePassword">
                <el-form  :model="passwordParam" :rules="rules" label-position="right" label-width="100px">
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="现使用密码" prop="oldPassword">
                                <el-input v-model="passwordParam.oldPassword"/>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="12">
                            <el-form-item label="新密码" prop="newPassword">
                                <el-input v-model="passwordParam.newPassword"/>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="changePassword = false">取消</el-button>
                    <el-button type="primary" @click="handleChangePassword()">确定</el-button>
                </div>
            </el-dialog>
        </div>
    </div>
</body>
<!-- 引入组件库 -->
<script src="../js/vue.js"></script>
<script src="../plugins/elementui/index.js"></script>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script src="../js/axios-0.18.0.js"></script>
<script>
    new Vue({
        el: '#app',
        data:{
            changePassword:false,//修改密码弹窗触发器
            //修改密码参数
            passwordParam:{
            },
            //List<Menu>
            menuList:[/*
                {
                    "path": "1",
                    "name": "工作台",
                    "icon":"fa-dashboard",
                    "children": []
                },
                {
                    "path": "2",
                    "name": "会员管理",
                    "icon":"fa-user-md",
                    "children": [
                        {
                            "path": "/2-1",
                            "name": "会员档案",
                            "linkUrl":"member.html",
                            "children":[]
                        },
                        {
                            "path": "/2-2",
                            "name": "体检上传",
                            "children":[]
                        },
                        {
                            "path": "/2-3",
                            "name": "会员统计",
                            "linkUrl":"all-item-list.html",
                            "children":[]
                        },
                    ]
                },
                {
                    "path": "3",
                    "name": "预约管理",
                    "icon":"fa-tty",
                    "children": [
                        {
                            "path": "/3-1",
                            "name": "预约列表",
                            "linkUrl":"ordersettinglist.html",
                            "children":[]
                        },
                        {
                            "path": "/3-2",
                            "name": "预约设置",
                            "linkUrl":"ordersetting.html",
                            "children":[]
                        },
                        {
                            "path": "/3-3",
                            "name": "套餐管理",
                            "linkUrl":"setmeal.html",
                            "children":[]
                        },
                        {
                            "path": "/3-4",
                            "name": "检查组管理",
                            "linkUrl":"checkgroup.html",
                            "children":[]
                        },
                        {
                            "path": "/3-5",
                            "name": "检查项管理",
                            "linkUrl":"checkitem.html",
                            "children":[]
                        },
                    ]
                },
                {
                    "path": "4",
                    "name": "健康评估",
                    "icon":"fa-stethoscope",
                    "children":[
                        {
                            "path": "/4-1",
                            "name": "中医体质辨识",
                            "linkUrl":"all-medical-list.html",
                            "children":[]
                        },
                    ]
                },
                {
                    "path": "5",     //菜单项所对应的路由路径
                    "name": "统计分析",     //菜单项名称
                    "icon":"fa-heartbeat",
                    "children":[//是否有子菜单，若没有，则为[]
                        {
                            "path": "/5-1",
                            "name": "会员数量折线图",
                            "linkUrl":"report_member.html",
                            "children":[]
                        },
                        {
                            "path": "/5-2",
                            "name": "套餐预约占比饼图",
                            "linkUrl":"report_setmeal.html",
                            "children":[]
                        },
                        {
                            "path": "/5-3",
                            "name": "运营数据统计",
                            "linkUrl":"report_business.html",
                            "children":[]
                        }
                    ]
                },
                {
                    "path": "6",     //菜单项所对应的路由路径
                    "name": "系统设置",     //菜单项名称
                    "icon":"fa-users",
                    "children":[//是否有子菜单，若没有，则为[]
                        {
                            "path": "/6-1",
                            "name": "权限管理",
                            "linkUrl":"member.html",
                            "children":[]
                        },
                        {
                            "path": "/6-2",
                            "name": "菜单管理",
                            "children":[]
                        },
                        {
                            "path": "/6-3",
                            "name": "角色管理",
                            "linkUrl":"all-item-list.html",
                            "children":[]
                        },
                        {
                            "path": "/6-4",
                            "name": "用户管理",
                            "linkUrl":"all-item-list.html",
                            "children":[]
                        }
                    ]
                }*/
            ],

            username:null//用户名
        },
        created:function () {
            axios.get('/user/getUsername.do').then(res=>{
                this.username = res.data.data;
                axios.get('/menu/getMenu.do?username='+this.username).then(res=>{
                    if(!res.data.flag){
                        this.$message({
                        message: res.data.message,
                        type: res.data.flag ? 'success':"error"
                        });
                    }
                this.menuList = res.data.data;
                })
            })
        },
        methods:{
            //权限不足提示
            showMessage(r){
                if(r == 'Error: Request failed with status code 403'){
                    //权限不足
                    this.$message.error('您暂时还没有该权限');
                    return;
                }else{
                    this.$message.error('未知错误');
                    return;
                }
            },
            editPassword() {
                this.passwordParam ={};
                this.changePassword = true;
            },
            handleChangePassword() {
                axios.post("../user/updatePassword.do",this.passwordParam)
                    .then(response => {
                        this.changePassword = false;
                        this.$message({
                            message: response.data.message,
                            type: response.data.flag ? 'success':"error"
                        });
                        if(response.data.flag) {
                            window.location.href = "../logout.do"
                        }
                    }).catch(error => {
                    this.showMessage(error);
                    console.log(error);
                });
            }

        }
    });
    $(function() {
            var wd = 200;
            $(".el-main").css('width', $('body').width() - wd + 'px');
    });
</script>
</html>
